Uniswap V1 introduction
Uniswap V1 provides people with decentralized token exchange services based on the Ethereum blockchain. Uniswap V1 provides a liquidity pool for ETH and ERC20 token exchange, which has the most striking features of decentralization, permissionless, and unstoppable among current DeFi projects. Uniswap V1 implements a decentralized exchange that does not need to consider the above characteristics. It does not require users to place pending orders (no orders), does not require overlapping demands, and can be bought and sold as they go. Thanks to the nature of ERC20 tokens, it also does not require users to deposit assets into a specific account. The advantage of the Uniswap V1 model lies in the automatic pricing according to the formula, and the automatic price adjustment is realized through the relationship between supply and demand. The key to the operating mechanism of Uniswap V1 is the establishment of a supply pool in which two currency assets, A and B, are stored. When the user exchanges A for B, the user's A will be sent to the supply pool, increasing the A in the supply pool, and at the same time, the B in the supply pool will be sent to the user. The key issue here is how to provide an exchange rate (pricing) for the exchange of A and B. The Uniswap V1 pricing model is very concise, and its core idea is a simple formula x * y = k . where x and y represent the quantities of the two assets respectively, and k is the product of the quantities of the two assets. Assuming that the product k is a fixed constant, it can be determined that when the value of variable x is larger, the value of y is smaller; on the contrary, the value of x is smaller, and the value of y is larger. From this it follows that when x is increased by p, y needs to be decreased by q to keep the equation constant. To do something more practical, replace x and y with the amount of reserves in the currency reserve that will be stored in the smart contract.